# Contributor: Kay Thomas <kaythomas@pm.me>
# Maintainer: Kay Thomas <kaythomas@pm.me>
pkgname=ergo
pkgver=2.12.0
pkgrel=1
pkgdesc="A modern IRC server (daemon/ircd) written in Go"
url="https://ergo.chat"
arch="all"
license="MIT"
options="!check" # no test suite
makedepends="go"
subpackages="$pkgname-doc $pkgname-openrc"
pkgusers="ergo"
pkggroups="ergo"
install="$pkgname.pre-install"
source="$pkgname-$pkgver.tar.gz::https://github.com/ergochat/ergo/archive/refs/tags/v$pkgver.tar.gz
	ergo.initd
	ergo.confd
	ircd.yaml
	"

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	make build
}

package() {
	install -Dm755 ergo -t "$pkgdir"/usr/bin/

	install -Dm644 "$srcdir"/ircd.yaml \
		-t "$pkgdir"/etc/ergo/

	install -dm755 -o ergo -g ergo \
		"$pkgdir"/var/ergo

	cp -a "$builddir"/languages \
		"$pkgdir"/var/ergo/languages

	install -Dm644 docs/*.md \
		-t "$pkgdir"/usr/share/doc/$pkgname/
	install -Dm644 LICENSE \
		-t "$pkgdir"/usr/share/licenses/$pkgname/

	install -Dm755 "$srcdir"/$pkgname.initd \
		"$pkgdir"/etc/init.d/$pkgname
	install -Dm644 "$srcdir"/$pkgname.confd \
		"$pkgdir"/etc/conf.d/$pkgname
}

sha512sums="
932179ec05b0c7e5868bb41ebbfa9cc57b8eb8f6e9a0aceaf12081b4b42c6cfa996142d1f9e52c39d2b674d92b409ef8d3792f164281e6bf3f3a5b97def1d3ac  ergo-2.12.0.tar.gz
1fd4e2a31ebbf7ade88294b18e2705a6caac4f0b0d402a3f324f929cc786d2dee104f600ec4213817f1fd7f22fa10c1303307ee342eb57968be9dfba7851e912  ergo.initd
c9856c141ab4b8b2dee63996678613a787d1aae8345d8baa2df9bc4427306f00b71a8a0fd7e30fd4e7b78cece982ec189ca1e73e703f2617e353d30fbd736491  ergo.confd
79d3608fdf0c271633e1b9fcbe7a654596c4433fb0a625e26d1ecb10826aeb1357200df758bc89f46a6077c189beff3f0218510296141ff6c1b0c76e4529e636  ircd.yaml
"
